package ch.unisi.inf.pfii.teamwhite.risk.core.io;

/**
 * 
 * @author Matteo Bellan: bellanm@lu.unisi.ch
 * @author Andrea Michelotti: micheloa@lu.unisi.ch
 * @author Ranganathan Ramasubramanian: ramasubr@lu.unisi.ch
 *
 */

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

//This class is used to read a file which contains the coordinates of each planet on the game frame
public final class CoordinatesReader {
	
	private final String fileName;

	public CoordinatesReader(final String fileName) {
		this.fileName = fileName;
	}

//	This method reads from a file and returns an ArrayList which contains each line
	public final ArrayList<String> fileReader() {
		final ArrayList<String> result = new ArrayList<String>();
		try {
			DataInputStream in = new DataInputStream(getClass().getResourceAsStream("maps/" + fileName));
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			String strLine;
			while ((strLine = br.readLine()) != null) {
					result.add(strLine);
			}
			in.close();
		} catch (Exception e) {
			System.err.println("Error: " + e.getMessage());
		}
		return result;
	}
}
